package code.structure.module.signIn.view
{
	import code.structure.manager.loader.DllLoaderManager;
	import code.tools.commponents.Component;
	import code.tools.commponents.Helpers;
	import code.untils.SWFNameConst;
	
	import flash.display.DisplayObjectContainer;
	import flash.display.MovieClip;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;

	/**
	 * 签到----天
	 * @author liangqian
	 * 
	 */	
	public class SignInDay extends Component
	{
		/** 过期未签到状态 */
		public static const STATE_NO_SIGN_IN:int = 1;
		/** 可签到状态 */
		public static const STATE_CAN_SIGN_IN:int = 2;
		/** 已签到状态 */
		public static const STATE_HAVE_SIGN_IN:int = 3;
		/** 不可签状态 */
		public static const STATE_NO_CAN_SIGN_IN:int = 4;
		
		public static const WIDTH:Number = 79.85;
		public static const HEIGHT:Number = 57.2;
		
		private var _mc:MovieClip;
		private var _dayTf:TextField;
		public function SignInDay(parent:DisplayObjectContainer, xpos:Number=0, ypos:Number=0)
		{
			super(parent, xpos, ypos);
		}
		
		override protected function addChildren():void
		{
			super.addChildren();
			_mc = new (DllLoaderManager.getInstance().getUIMaterial(SWFNameConst.SIGN_IN_PANEL,'day_mc')as Class)as MovieClip;
			addChild(_mc);
			
			_dayTf = Helpers.FormatTextField(this,8,5,50,TextFieldAutoSize.LEFT,0xffffff,'',14);
			addChild(_dayTf);
		}
		
		override protected function init():void
		{
			setSize(WIDTH,HEIGHT);
			super.init();
		}
		
		public function setData(day:int,state:int = 1):void
		{
			if(day == -1)
			{
				this.visible = false;
				return;
			}
			this.visible = true;
			_dayTf.text = day + '';
			_mc.gotoAndStop(state);
			switch(state)
			{
				case STATE_NO_SIGN_IN:
					_dayTf.textColor = 0xffffff;
					break;
				case STATE_CAN_SIGN_IN:
					_dayTf.textColor = 0xAD5419;
					break;
				case STATE_HAVE_SIGN_IN:
					_dayTf.textColor = 0xAD5419;
					break;
			}
		}
	}
}